package com.czk.model.iterator;

import java.util.ArrayList;
import java.util.Iterator;
import java.util.List;

/**
 * @Author:ChenZhangKun
 * @Date: 2020/5/11 20:47
 */
public class OutputImpl {
    // 学院的集合
    List<College> collegeList=new ArrayList<>();
    public OutputImpl(List<College> collegeList){
        this.collegeList=collegeList;
    }
    // 输出系
    public void printDepartment(Iterator iterator){
        while (iterator.hasNext()){
            Department next = (Department) iterator.next();
            System.out.println(next.getName());
        }
    }
    // 取出所有的学院
    public void printCollege(){
        Iterator<College> collegeIterator = collegeList.iterator();
        while (collegeIterator.hasNext()){
            College college = collegeIterator.next();
            System.out.println("学院名称"+college.getName());
            printDepartment(college.createIterator());
        }
    }
}
